<template>
    <div class="warpper">
        <div class="top">
            <div class="head">
                <span class="l"></span>
                <span>我的</span>
                <span class="r" @click="loingOut" >退出登录</span>
            </div>
            <div class="statis">
                <div class="s-cont">
                    <div class="titels">
                        <span>总持币(个)</span>
                        <span>邀请人数(人)</span>
                    </div>
                    <div class="nums">
                        <span class="l">{{coinData.coin}}</span>
                        <span class="r">{{coinData.inviteCount}}</span>
                    </div>
                </div>
            </div>
            <div class="allData">
                <div class="intro-cont">
                    <div class="left">
                        <div class="t1">WKC打工人币</div>
                        <div class="t2">每个持币的币友，都将是WKC币老板之一！</div>
                    </div>
                    <div class="right">
                        <a href="http://wkcoin.cc/" class="btn" >前往了解</a>
                    </div>
                </div>
            </div>
        </div>
        <div class="bottom">
            <div class="operate">
                <div class="item l" @click="tb">
                    <div class="img">
                        <img src="../../assets/images/tb.png" />
                    </div>
                    <div class="t">提币</div>
                </div>
                <div class="m"></div>
                <div class="item r" @click="invite">
                    <div class="img">
                        <img src="../../assets/images/invite.png" />
                    </div>
                    <div class="t">邀请新用户</div>
                </div>
            </div>
            <div class="tab-record">
                <van-tabs @click="onClick" v-model="active" color="#3373FF" background="transparent">
                    <van-tab title="提币记录">
                        <div v-if="listTb && listTb.length > 0" class="list-tb">
                            <div class="item" v-for="item in listTb">
                                <div class="row1">
                                    <div class="l">从账户转出至钱包</div>
                                    <div class="r">
                                        <span v-if="item.schedule === 0" >等待转入</span>
                                        <span v-else style="color: #07c160">已提现</span>
                                    </div>
                                </div>
                                <div class="row2">
                                    <div class="l">{{item.createDate}}</div>
                                    <div class="r">-{{item.coin}} 个</div>
                                </div>
                            </div>
                        </div>
                        <van-empty v-else description="暂无数据" />
                    </van-tab>
                    <van-tab title="邀请记录">
                        <div class="list-yq" v-if="listYq && listYq.length > 0"  >
                            <div class="item" v-for="item in listYq">
                                <div class="row0">
                                    <div class="l">{{item.userName}}</div>
                                    <div class="r">{{item.createDate}}</div>
                                </div>
                                <div class="row1">
                                    <div class="l">邀请奖励</div>
                                    <div class="m">好友邀请人数</div>
                                    <div class="r">获得赠送</div>
                                </div>
                                <div class="row2">
                                    <div class="l">+{{item.reward}}</div>
                                    <div class="m">+{{item.count}}</div>
                                    <div class="r">+{{item.sonReward}} 个</div>
                                </div>
                            </div>
                        </div>
                        <van-empty v-else description="暂无数据" />
                    </van-tab>
                </van-tabs>
            </div>
        </div>
    </div>
</template>

<script>
    import TopHeader from '@/components/TopHeader.vue'
    import formlogin from '@/components/formlogin.vue'
    import Vue from 'Vue';
    import { Empty } from 'vant';
    Vue.use(Empty);
    import {userInfo, withdrawal, invite} from "@/utils/request"
    import {mapState} from 'vuex'
    import {Toast} from "vant";
    export default {
        name: "login",
        components: {
            TopHeader,
            formlogin
        },
        data () {
            return {
                coinData: {
                    // 邀请码
                    inviteCode: ''
                },
                avatar:require('@/assets/images/logo.png'),
                active: 0,
                listTb: [{
                    num: 20
                }],
                listYq: [{
                    num: 20
                },{
                    num: 30
                },{
                    num: 30
                },{
                    num: 30
                },{
                    num: 30
                },{
                    num: 30
                }],
            }
        },
        created() {
            this.init();
        },
        computed:{
            ...mapState([
                "userInfo",

            ])
        },
        methods:{
            onClick(name) {
                this.init();
            },
            init() {
                userInfo().then(res => {
                    if (res.code === 200) {
                        this.coinData = res.data || {};
                    } else {
                        Toast.fail(res.msg || '请求失败');
                    }
                });
                withdrawal().then(res => {
                    console.log(res)
                    if (res.code === 200) {
                        this.listTb = res.rows || [];
                    } else {
                        Toast.fail(res.msg || '请求失败');
                    }
                });
                invite().then(res => {
                    console.log(res)
                    if (res.code === 200) {
                        this.listYq = res.rows || [];
                    } else {
                        Toast.fail(res.msg || '请求失败');
                    }
                });
            },
            tb(){
                this.$router.push({
                    path: '/extract',
                    query: {
                        maxNum: this.coinData.coin,
                        walletAddress: this.coinData.walletAddress
                    }
                })
            },
            invite(){
                this.$router.push({
                    path: '/invite',
                    query: {
                    }
                })
            },
            loingOut() {
                this.$store.commit('setToken', '');
                this.$router.push({
                    path: '/login'
                })
            },
            isTruePhone(str){
                var reg = /^1[34578]\d{9}$/;
                if(!reg.test(str)){
                    return false;
                }
                return true;

            }

        }
    }
</script>

<style scoped lang='less'>
    .warpper{
        height: 100vh;
        background: linear-gradient(180deg, #359AE4 0%, #335CEC 76%, #4E70EB 100%);
        position: relative;
        /*padding-top: 285px;*/
        .top{
            top: 0;
            right: 0;
            left: 0;
            .statis{
                padding:  0 24px;
                .s-cont{
                    padding: 18px 22px 22px;
                    color: #fff;
                    height: 100px;
                    .titels{
                        display: flex;
                        justify-content: space-between;
                        margin-bottom: 24px;
                        font-size: 12px;
                    }
                    .nums{
                        display: flex;
                        justify-content: space-between;
                        font-size: 24px;
                    }
                }
            }
            .allData{
                height: 92px;
                padding:  0 24px;
                .intro-cont {
                    background: rgba(73,151,254,.3);
                    height: 100%;
                    border-radius: 20px;
                    display: flex;
                    justify-content: space-between;
                    color: #fff;
                    padding:  0 5%;
                    align-items: center;
                    .left {
                        .t1 {
                            font-size: 16px;
                            margin-bottom: 9px;
                        }
                        .t2 {
                            font-size: 9px;
                            color: rgba(255, 255, 255, 0.65)
                        }
                    }
                    .right {
                        .btn{
                            display: block;
                            width: 72px;
                            height: 25px;
                            line-height: 23px;
                            font-size: 12px;
                            border-radius: 12px;
                            border: 1px solid #FFFFFF;
                            text-align: center;
                            color: #fff;
                        }
                    }
                }
            }
        }
        .bottom{
            min-height: 100%;
            background: #fff;
            border-top-left-radius: 20px;
            border-top-right-radius: 20px;
            position: relative;
            z-index: 5;
            padding-top: 132px;
            top: -10px;
            .operate{
                display: flex;
                justify-content: space-between;
                align-items: center;
                width: 100%;
                margin: 0 auto 25px;
                position: absolute;
                top: 18px;
                left: 0;
                right: 0;
                padding: 0 19% 20px;
                border-bottom: 12px solid RGBA(248, 248, 248, 1);
                .m{
                    width: 1px;
                    height: 38px;
                    background: rgba(58, 119, 241, 0.2);
                }
                .item{
                    text-align: center;
                    .t{
                        color: #666;
                        font-size: 13px;
                    }
                    .img{
                        margin-bottom: 12px;
                    }
                    img{
                        width: 56px;
                    }
                }
            }
        }
    }
    .head{
        text-align: center;
        color: #fff;
        font-size: 14px;
        line-height: 11vh;
        display: flex;
        justify-content: space-between;
        padding:  0 15px;
        .l , .r{
            width: 75px;
        }
        .r{
            opacity: .8;
            color: #fff;
            font-size: 12px;
        }
    }
    .list-tb{
        padding-top: 10px;
        .item{
            padding: 13px 20px;
            border-bottom: 1px solid rgba(0, 0, 0, 0.1);
            .row1, .row2{
                display: flex;
                justify-content: space-between;
            }
            .row1{
                margin-bottom: 10px;
                .l {
                    font-size: 14px;
                    color: #121212;
                }
                .r {
                    font-size: 12px;
                    color: #999;
                }
            }
            .row2{
                .l {
                    font-size: 12px;
                    color: #999;
                }
                .r {
                    font-size: 14px;
                    color: #D32E2E;
                }
            }
        }
    }
    .list-yq{
        padding-top: 10px;
        .item{
            padding: 13px 20px;
            border-bottom: 1px solid rgba(0, 0, 0, 0.1);
            .row0, .row1, .row2{
                display: flex;
                justify-content: space-between;
            }
            .row0{
                margin-bottom: 15px;
                .l {
                    font-size: 14px;
                    color: #121212;
                }
                .r {
                    font-size: 12px;
                    color: #999;
                }
            }
            .row1{
                margin-bottom: 10px;
                font-size: 12px;
                color: #999;
                .l {
                }
                .m{
                }
                .r {
                }
            }
            .row2{
                font-size: 14px;
                .l {
                    color: #16AE59;
                }
                .m {
                    color: #3B74F1;
                }
                .r {
                    color: #DCA43C;
                }
            }
        }
    }
</style>

